package com.wyh.service.serviceImpl.g3serviceimpl;

import com.wyh.domain.po.g3po.Charging;
import com.wyh.service.g3service.BillingForMigrationInAndOutSituationsService;
import com.wyh.service.g3service.ChargingService;
import com.wyh.service.g3service.GenerateBillingContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * @Author: cc
 * @Date: 2024/06/17/10:31
 **/
@Service
public class BillingForMigrationInAndOutSituationsServiceImpl implements BillingForMigrationInAndOutSituationsService {
    @Autowired
    GenerateBillingContent generateBillingContent;
    @Autowired
    ChargingService chargingService;
    @Override
    public int billingForMigrationInAndOutSituations(Integer customerid, int days) {
        List<Charging> chargingList=generateBillingContent.updateBilling(customerid,days);
        int result=0;
        for (Charging charging:chargingList) {
            int res=chargingService.addCharging(charging);
            if(res>0){
                result++;
            }
        }
        return result;
    }
}
